<include file="public@header"/>

</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Student/index')}">所有学生</a></li>
        <li><a href="{:url('Student/add')}">添加学生</a></li>
    </ul>
        <form class="well form-inline margin-top-20" method="get"  action="{:url('Student/index')}">
            姓名：
            <input type="text" class="form-control" value="{$Request.param.name}" name="name" style="width: 150px;"  placeholder="请输入学生姓名">
            <select name="" class="form-control" id="school">
                <option value="">请选择学校</option>
                <foreach name="school" item="vo">
                    <option value="{$vo.id}" <if $vo.id == $Request.param.school_id> selected </if>>{$vo.name}</option>
                </foreach>
            </select>
            <select name="" class="form-control" id="major" style="width: 250px;">
                <option value="">选择专业</option>
                <foreach name="class" item="vo">
                <option value="{$vo.id}" <if $vo.id == $Request.param.major_id> selected </if>>{$vo.major_name}</option>
                </foreach>
            </select>
            <select name="class_id" class="form-control" id="class">
                <option value="">请选择班级</option>
                <foreach name="class" item="vo">
                    <option value="{$vo.id}"<if $vo.id == $Request.param.class_id> selected </if>>{$vo.class_name}</option>
                </foreach>
            </select>
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:url('Student/index')}">清空</a>
        </form>
    <form  method="post" class="margin-top-20" action="{:url('Student/delAll')}">
        <button class="btn btn-xs btn-danger" onclick="delCheck()">批量删除</button>
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>
                    <input type="checkbox" onclick="checkAll(this)">
                </th>
                <th>ID</th>
                <th>头像</th>
                <th>姓名</th>
                <th>性别</th>
                <th>年龄</th>
                <th>身份证</th>
                <th>地址</th>
                <th>所在班级</th>
                <th>所在专业</th>
                <th>所在学校</th>
                <th>日常成绩</th>
                <th>{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="data" item="vo">
                <tr>
                    <td>
                    <input type="checkbox" name="ids[]" value="{$vo.id}" >
                    </td>
                    <td>{$vo.id}</td>
                    <td>
                        <if $vo.image != "">
                        <img src="/upload/{$vo.image}" width="40" height="40">
                        </if>
                    </td>
                    <td>
                        <a href="javascript:parent.openIframeLayer('{:url('score/index_student')}?sid={$vo.score.sid}')">
                        {$vo.name}
                        </a>
                    </td>
                    <td>
                        <if $vo.sex==1><?php echo'男';?></if>
                        <if $vo.sex==2 ><?php echo'女';?></if>
                    </td>
                    <td>{$vo.age}</td>
                    <td>{$vo.idcard}</td>
                    <td>{$vo.address}</td>
                    <td>{$vo.classroom.class_name}</td>
                    <td>{$vo.classroom.major.major_name}</td>
                    <td>{$vo.classroom.major.school.name}</td>
                    <td>{$vo.Plist.point.score}</td>
                    <td>
                        <a class="btn btn-xs btn-primary" href="{:url('Plist/score')}?sid={$vo.id}">详情</a>
                        <a class="btn btn-xs btn-success" href="{:url('Student/edit')}?id={$vo.id}">{:lang('EDIT')}</a>
                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('Student/delete')}?id={$vo.id}">{:lang('DELETE')}</a>
                    </td>
                </tr>
            </foreach>
            </tbody>

        </table>
        <div class="pagination" style = "margin-left:500px">
            <div class="pagination" >
                {$page}
            </div>
            <div class="">
                共 {$data->total()} 条数据，当前第 {$data->currentPage()} 页，共 {$data->lastPage()} 页
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    //全选
    function checkAll(e) {
        var item = document.getElementsByName('ids[]');
        for (var i = 0; i < item.length; i++)
        {
            item[i].checked = e.checked;
        }
    }
    //全选删除
    function delCheck() {
        var isCheck = false;
        var item = document.getElementsByName('ids[]');
        for (var i = 0; i < item.length; i++)
        {
            if (item[i].checked)
            {
                isCheck = true;
            }
        }
        if (isCheck)
        {
            return confirm('确定删除吗？');
        } else {
            alert('请至少选择一项！');
            // layer.msg('请至少选择一项');
            return false;
        }
    }


</script>
<script>

    $(function () {
        // 监听学校下拉框的值改变
        $('#school').on('change',function () {
            var schoolId= $(this).val();
            //ajax
            $.ajax({
                url:'{:url("student/Get_major")}',

                data: {school_id:schoolId},
                success: function (r) {
                    $('#major').html(r);
                },
                error: function () {
                    alert('数据获取失败！');
                }
            });
        });
    })
</script>
<script>

    $(function () {
        // 监听学校下拉框的值改变
        $('#major').on('change',function () {
            var majorId= $(this).val();
            //ajax
            $.ajax({
                url:'{:url("student/Get_class")}',
                data: {major_id:majorId},
                success: function (r) {
                    $('#class').html(r);
                },
                error: function () {
                    alert('数据获取失败！');
                }
            });
        });
    })

</script>
</body>
</html>